package com.helloscala.model

import com.helloscala.common.SexCode
import org.joda.time.DateTime

import MyPostgresJodaSupport._
import MyPostgresDriver.simple._

/**
 * Created by yangjing on 14-1-18.
 */
case class User(// 用于个人空间标识。只能使用英文字母、数字和下划线，且必须使用字母开头，大于等于3个字符，小于等于32个字符。
                id: String,

                email: String,

                nick: Option[String] = None,

                sex: Option[SexCode.Value] = None,

                safe_email: Option[String] = None,

                signature: Option[String] = None,

                created_at: DateTime = DateTime.now())

class Users(tag: Tag) extends Table[User](tag, "m_user") {
  def id = column[String]("id", O.PrimaryKey, O.DBType("varchar(32)"))

  def email = column[String]("email")

  def nick = column[String]("nick", O.Nullable)

  def sex = column[SexCode.Value]("sex", O.Nullable)

  def safe_email = column[String]("safe_email", O.Nullable)

  def signature = column[String]("signature", O.Nullable)

  def created_at = column[DateTime]("created_at")

  def * = (id, email, nick.?, sex.?, safe_email.?, signature.?, created_at) <>(User.tupled, User.unapply)
}
